package com.shudes.util;

import java.util.*;

abstract public class EnumeratedType implements Comparable {
	
	protected Long id;
	protected String description; 
	
	protected EnumeratedType(long id, String description) {
		this(id); 
		this.description=description;
	}
	
	public EnumeratedType(long id) { 
		this.id=id;
	}
	
	public Long getId() {
		return id;
	}
	
	public String getDescription() { 
		return description; 
	}
	
	@Override
	public String toString() { 
		return (description!=null) ? description : ""+id; 
	}
	
	@Override
	public boolean equals(Object o) { 
		return ((o!=null) 
				&& (getClass().equals(o.getClass()))
				&& (this.hashCode()==o.hashCode()));
	}
	
	@Override
	public int hashCode() { 
		return (""+id).hashCode(); 
	}
	
	public int compareTo(Object o) {
		return id.compareTo(((EnumeratedType) o).getId());
	}	
	
}
